package com.zjy.dao;

import com.zjy.entity.Book;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @program: springboot-jpa
 * @ClassName BookRepository
 * @description:
 * @author: Ats
 * @create: 2025-04-19 15:50
 * @Version 1.0
 */
@Repository
public interface BookRepository extends JpaRepository<Book, Integer> {

 Book findByAuthorAndStatus(String author, String status);

 @Modifying
 @Transactional
 @Query("delete from Book b where b.id= :id")
 List<Book> deleteBookById(@Param("id") Integer id);

}

